package com.kzw.oa.comm.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kzw.core.bean.Msg;
import com.kzw.core.orm.Page;
import com.kzw.core.orm.PageRequest;
import com.kzw.core.orm.StringPropertyFilter;
import com.kzw.core.util.ExtjsUtil;
import com.kzw.core.util.json.JSON;
import com.kzw.core.util.web.ResponseUtils;
import com.kzw.oa.comm.model.Log;
import com.kzw.oa.comm.service.LogService;

/**
 * @author kzwang
 */
@Controller
@RequestMapping("/comm/log/")
public class LogAction {

	@Autowired
	private LogService logService;

	/**
	 * 显示列表
	 */
	@RequestMapping("list")
	public void list(HttpServletRequest request, HttpServletResponse response) {
		PageRequest pageRequest = ExtjsUtil.getPageReq(request);
		List<StringPropertyFilter> filters = ExtjsUtil.getFilters(request);

		Page<Log> page = logService.search2(pageRequest, filters);
		String json = new JSON(page).setDateFormater("yyyy-MM-dd HH:mm:ss").buildWithFilters(3);
		ResponseUtils.renderJson(response, json);
	}

	/**
	 * 批量删除
	 */
	@ResponseBody
	@RequestMapping("multiDel")
	public Msg multiDel(HttpServletRequest request) {
		String[] ids = request.getParameterValues("ids");
		logService.remove(ids);
		return new Msg();
	}

}
